<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui">

    <body>

        <ui:composition template="./../Template/AdminTemplate.xhtml">

            <ui:define name="content">
                <f:view>
                    <h:form>
                        <p:fieldset legend="Set Admin">  
                        <p:dataTable id="user" value="#{userControl.allUser}" var="item" paginator="true" rows="5" tableStyle="width:auto" widgetVar="carsTable" emptyMessage="No Event found with given criteria">                                                              
                            <f:facet name="header">  
                                <p:outputPanel>  
                                    <h:outputText value="Set Admin/Active:" />  
                                    <p:inputText id="globalFilter" onkeyup="carsTable.filter()" style="width:150px" />  
                                </p:outputPanel>  
                            </f:facet> 
                            <p:column filterBy="#{item.userName}" sortBy="#{item.userName}" headerText="UserName" footerText="contains" filterMatchMode="contains" >               
                                <h:outputText value="#{item.userName}"/>
                            </p:column>
                            <p:column filterBy="#{userControl.convertSex(item)}"  sortBy="#{userControl.convertSex(item)}" headerText="Gender" footerText="Exact" filterOptions="#{userControl.sexoption()}" filterMatchMode="exact">                                
                                <h:outputText value="#{userControl.convertSex(item)}"/>
                        </p:column>
                            <p:column headerText="FullName">                                
                                <h:outputText value="#{item.fullName}"/>
                            </p:column>
                            <p:column headerText="Birthday">                                
                                <h:outputText value="#{item.birthday}">
                                    <f:convertDateTime pattern="MM/dd/yyyy" />
                                </h:outputText>
                            </p:column>                                                       
                            <p:column headerText="Email">                                
                                <h:outputText value="#{item.email}"/>
                            </p:column>
                            <p:column filterBy="#{item.departmentName}" sortBy="#{item.departmentName}" headerText="Department" footerText="Exact" filterOptions="#{userControl.createFilterOptions()}" filterMatchMode="exact">                                
                                <h:outputText value="#{item.departmentName}"/>
                            </p:column>
                            
                            <p:column headerText="Active">                               
                                <p:selectOneRadio value="#{item.isActive}">
                                    <f:selectItem itemLabel="Yes" itemValue="true"/>
                                    <f:selectItem itemLabel="No" itemValue="false"/>
                                </p:selectOneRadio>                                
                            </p:column>
                            <p:column headerText="Admin">
                                <p:selectOneRadio value="#{item.isAdmin}">
                                    <f:selectItem itemLabel="Yes" itemValue="true"/>
                                    <f:selectItem itemLabel="No" itemValue="false"/>
                                </p:selectOneRadio>
                            </p:column>                            
                            <p:column headerText="SetAdmin">
                            <p:commandButton style="font-size: 11px;" value="Save"  onclick="confirmation.show()" >
                                <f:setPropertyActionListener value="#{item}" target="#{userControl.selectedtuser}" />
                            </p:commandButton>
                            <p:confirmDialog id="confirmDialog" message="Are you sure want set Admin for this User?"  
                                             header="Initiating destroy process" severity="alert" widgetVar="confirmation">
                                <p:commandButton id="confirm" style="font-size: 11px;" actionListener="#{userControl.savesetadmin(userControl.selectedtuser)}" value="Yes Sure" oncomplete="confirmation.hide()"/>
                                  <p:commandButton id="decline" style="font-size: 11px;" value="Not Yet" onclick="confirmation.hide()" />   
                            </p:confirmDialog>
                    </p:column>
                        </p:dataTable>
                        </p:fieldset>
                    </h:form>
                </f:view>
            </ui:define>

        </ui:composition>

    </body>
</html>
